﻿
using System;
using Microsoft.Practices.ServiceLocation;

namespace Mockery.Core.CommonContainer
{
    /// <summary>
    /// This interface is implemented by the container specific implementations allow for the abstraction of 
    /// the container building process
    /// </summary>
    public interface ICommonContainerBuilder
    {
        /// <summary>
        /// This method requires the container builder to spawn a new, empty
        /// container builder.  This is to mitigate the time to locate the container builder
        /// </summary>
        /// <returns>an ICommonContainerBuilder instance</returns>
        ICommonContainerBuilder New();

        /// <summary>
        /// Provides the ability to register an instance for Ioc resolution as a singleton
        /// </summary>
        /// <typeparam name="TType">type of incoming instance either explicit or implicit</typeparam>
        /// <param name="resolveType">type used in container resolution</param>
        /// <param name="instance">resolvable instance</param>
        void RegisterInstance<TType>(Type resolveType, TType instance);

        /// <summary>
        /// Registers a type for Ioc resolution as a singleton
        /// </summary>
        /// <typeparam name="TType">Type to by registered</typeparam>
        /// <typeparam name="TResolveType">Type to register as</typeparam>
        void RegisterType<TType, TResolveType>() where TType : TResolveType;

        /// <summary>
        /// Registers a type for Ioc resolution where the instance type and the 
        /// resolution type are the same
        /// </summary>
        /// <typeparam name="TType">Type to be registered and instantiated on resolution</typeparam>
        void RegisterType<TType>();


        /// <summary>
        /// Provides the ability to create a common ServiceLocator implmentation
        /// </summary>
        /// <returns>CommonServiceLocator implementation</returns>
        IServiceLocator ServiceLocator { get; }
    }
}
